package com.joolun.weixin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.joolun.common.corp.TenantContext;
import com.joolun.common.utils.DateUtils;
import com.joolun.system.domain.ScrmChannelStatistics;
import com.joolun.weixin.mapper.ScrmChannelStatisticsMapper;
import com.joolun.weixin.service.IScrmChannelStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * 渠道数据统计Service业务层处理
 * 
 * @author joolun
 * @date 2025-03-19
 */
@Service
public class ScrmChannelStatisticsServiceImpl extends  ServiceImpl<ScrmChannelStatisticsMapper, ScrmChannelStatistics> implements IScrmChannelStatisticsService
{
    @Autowired
    private ScrmChannelStatisticsMapper scrmChannelStatisticsMapper;

    /**
     * 查询渠道数据统计
     * 
     * @param id 渠道数据统计主键
     * @return 渠道数据统计
     */
    @Override
    public ScrmChannelStatistics selectScrmChannelStatisticsById(Long id)
    {
        return scrmChannelStatisticsMapper.selectScrmChannelStatisticsById(id);
    }

    /**
     * 查询渠道数据统计列表
     * 
     * @param scrmChannelStatistics 渠道数据统计
     * @return 渠道数据统计
     */
    @Override
    public List<ScrmChannelStatistics> selectScrmChannelStatisticsList(ScrmChannelStatistics scrmChannelStatistics)
    {
        // 添加主体id
        scrmChannelStatistics.setExtCorpId(TenantContext.getTenantId());
        return scrmChannelStatisticsMapper.selectScrmChannelStatisticsList(scrmChannelStatistics);
    }

    /**
     * 渠道数据汇总列表
     *
     * @param params 渠道数据统计
     * @return 渠道数据统计
     */
    @Override
    public List<ScrmChannelStatistics> summary(Map<String, Object> params)
    {
        // 添加主体id
        params.put("corpId", TenantContext.getTenantId());
        return scrmChannelStatisticsMapper.summary(params);
    }

    /**
     * 新增渠道数据统计
     * 
     * @param scrmChannelStatistics 渠道数据统计
     * @return 结果
     */
    @Override
    public int insertScrmChannelStatistics(ScrmChannelStatistics scrmChannelStatistics)
    {
        // 添加主体id
        scrmChannelStatistics.setExtCorpId(TenantContext.getTenantId());
        scrmChannelStatistics.setCreateTime(DateUtils.getNowDate());
        return scrmChannelStatisticsMapper.insertScrmChannelStatistics(scrmChannelStatistics);
    }

    /**
     * 修改渠道数据统计
     * 
     * @param scrmChannelStatistics 渠道数据统计
     * @return 结果
     */
    @Override
    public int updateScrmChannelStatistics(ScrmChannelStatistics scrmChannelStatistics)
    {
        scrmChannelStatistics.setUpdateTime(DateUtils.getNowDate());
        return scrmChannelStatisticsMapper.updateScrmChannelStatistics(scrmChannelStatistics);
    }

    /**
     * 批量删除渠道数据统计
     * 
     * @param ids 需要删除的渠道数据统计主键
     * @return 结果
     */
    @Override
    public int deleteScrmChannelStatisticsByIds(Long[] ids)
    {
        return scrmChannelStatisticsMapper.deleteScrmChannelStatisticsByIds(ids);
    }

    /**
     * 删除渠道数据统计信息
     * 
     * @param id 渠道数据统计主键
     * @return 结果
     */
    @Override
    public int deleteScrmChannelStatisticsById(Long id)
    {
        return scrmChannelStatisticsMapper.deleteScrmChannelStatisticsById(id);
    }
}
